package juego.main;


import java.awt.*;

import javax.swing.*;

public class SplashScreen extends JWindow {
    
    protected int duration;
	protected static PlayerThread elReproductor=new PlayerThread("./music/Miku-Hatsune-Polka.mp3");

    
    public SplashScreen(int d) {
        duration = d;
    }

    public void showSplash() {
        
        JPanel content = (JPanel)getContentPane();
        content.setBackground(Color.white);
      
        int width = 1100;
        int height =600;
        Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
        int x = (screen.width-width)/2;
        int y = (screen.height-height)/2;
        setBounds(x,y,width,height);

        JPanel panel=new JPanel();
        this.add(panel);
        
        panel.setBackground(new Color(0,0,0,0));
        JLabel jLabel1 = new JLabel();
		jLabel1.setIcon(new ImageIcon(getClass().getClassLoader().getResource("juego/graficos/CarotaMario.jpg")));
	    panel.add(jLabel1);
		
		JLabel jLabel3=new JLabel();
		jLabel3.setIcon((new ImageIcon(getClass().getClassLoader().getResource("juego/splash/animated_timer_bar.gif"))));
		jLabel3.setBounds(435,0,400,400);
		jLabel1.add(jLabel3);
		setVisible(true);
        try { Thread.sleep(duration); } catch (Exception e) {}
        
        setVisible(false);
        toFront();
    }
    
    public void showSplashAndExit() {
        
        showSplash();
        System.exit(0);
        
    }
    
    public static void main(String[] args) {
        
        SplashScreen splash = new SplashScreen(5000);
        splash.showSplash();
    
       
        Juego inst=new Juego();
       	inst.setLocationRelativeTo(null);
		inst.setVisible(true);
		int width = 1100;
        int height =600;
		Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
	    int x = (screen.width-width)/2;
	    int y = (screen.height-height)/2;
		inst.setBounds(x, y, 1100, 600);
     
        
    }
}